#include <iostream>
#include <vector>
using namespace std;

int binary_search(vector<int>& nums,int target){
    int low = 0;
    int high = nums.size();
    while (low <= high)
    {
        int mid = low + (high - low )/ 2;
        int guess = nums[mid];
        if(guess == mid){
            return guess;
        }else if (guess < target)
        {
            low = mid + 1;
        }else
        {
            high = mid - 1;
        }
        
        return mid;
    }

    return -1;
    
}

int main(){
    int ret;
    vector<int> a = {1,3,4,9,10,11,16,19,20,25,30};

    ret = binary_search(a,11);

    cout << "要找的数的位置是:"<< ret << endl;

    return 0;
}